package com.itheima.d01_file;

import com.sun.tools.javac.Main;

import java.io.File;
import java.io.IOException;
import java.util.Map;

public class Test2 {
    public static void searchFile(File dir , String fileName) throws IOException {
        if (dir == null || !dir.exists() || dir.isDirectory()) {
            return;
        }
        File[] files = dir.listFiles();
        if (files != null && files.length > 0) {
            for (File file : files) {
                if (file.isFile()) {
                    if (file.getName().contains(fileName)) {
                        System.out.println("找到了"+file.getAbsolutePath());
                        Runtime.getRuntime().exec("notepad.exe " + file.getAbsolutePath());
                    }
                } else {
                    searchFile(file, fileName);
                }
            }

        }


    }

    public static void main(String[] args) throws IOException {
        searchFile(new File("D:\\"), "a");
    }
}
